 /* @author: Chang L. Kim <changk82@hotmail.com>
  * @author: Chao Li
  */

#ifndef SEEDCOUNTER_H
#define SEEDCOUNTER_H

#include <math.h>
#include <QString>
#include <utility>
#include <QVector>
#include <iostream>
#include <cv.h>
#include <highgui.h>
#include "BlobResult.h"
#include <QDebug>

using namespace cv;
class SeedCounter
{
public:
    SeedCounter();
    ~SeedCounter();
    bool isFormat(const QString &file);
    bool addFile(const QString &file);
    int numberOfSeeds();
    int avgArea();
    int avgPeri();
    double avgRoundness();
    double avgAspect();
    int avgMajor();
    int avgMinor();
    Mat getResultImg() { return resultImg; }

private:
    void run(const Mat &img_resized, const Mat &img_mask);
    Mat resizeImage(const Mat& image);
    Mat findROIMask(const Mat& image, int& d);
    Mat cropImage(const Mat& image, const Mat& imageMask);
    Mat customNoiseFilter(const Mat& image, int r_threshold, int g_threshold, int b_threshold);
    Mat automatedSegmentation(const Mat& image, const Mat& imageMask);
    Mat calculateSeeds(const Mat& imageGray, const Mat& imageColor, int min_area, int max_area);

    int total;
    int masksize;
    int red_thres;
    int green_thres;
    int blue_thres;
    int seed_thres;
    int min_area;
    int max_area;
    double PI;
    int blobareaavg;
    int blobperimeteravg;
    double blobroundnessavg;
    double blobaspectavg;
    int blobmajaxisavg;
    int blobminaxisavg;

    Mat resultImg;
};

#endif // SEEDCOUNTER_H
